package org.richin.support.web.struts;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.richin.support.biz.EntityManager;
import org.richin.support.orm.Page;

@SuppressWarnings("unchecked")
public abstract class PageAction <T, M extends EntityManager> extends BaseCRUDAction<T, M>{
	/**
	 * 列出所有对象的Action函数.
	 */
	public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response)throws Exception  {
		request.setAttribute(getEntityListName(), doListEntity());
		return mapping.findForward(LIST);
	}
	/**
	 * 获取业务对象列表的函数.
	 */
	protected Page<T> doListEntity() {
		Page<T> page =new Page<T>(15);
		return getEntityManager().getAll(page);
	}
}
